package com.vincce.sport.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.vincce.sport.entity.TeamBackBoardData;
import com.vincce.sport.entity.TeamDataTask;
import com.vincce.sport.mapper.TeamDataTaskMapper;

@Controller
@RequestMapping("/teamBackboardRankApi")
public class TeamAverageBackboardRankingController extends BaseController{

	@Autowired
	private TeamDataTaskMapper teamDataTaskMapper;
	
	@RequestMapping("/data")
	@ResponseBody
	public String data(HttpServletRequest request,HttpServletResponse response){
		String seasonId = request.getParameter("seasonId");
		String pageSize = request.getParameter("limit");
		String pageindex = request.getParameter("offset");
		Map<String,Object> resMap = new HashMap<String, Object>();
		//if(checkIp(request)){
			try {
				Map<String,Object> map = new HashMap<String, Object>();
				map.put("seasonId", seasonId);
				map.put("pageSize", (pageSize == null || "".equals(pageSize)) ? 20 : pageSize);
				map.put("pageindex", (pageindex == null || "".equals(pageindex)) ? 0 : pageindex);
				List<TeamBackBoardData> teamDataTask = teamDataTaskMapper.queryTeamAverageBackboardRankingContantsName(map);
				resMap.put("list", teamDataTask);
				resMap.put("suc", "true");
				resMap.put("msg", "调用接口成功");
			} catch (Exception e) {
				// TODO: handle exception
				resMap.put("suc", "false");
				resMap.put("msg", "调用接口失败");
				e.printStackTrace();
			}
			
		/*}else{
			resMap.put("suc", "false");
			resMap.put("msg", "此IP地址无效");
		}*/
		return JSON.toJSONString(resMap);
	}
}
